package com.java01.file.inputstream;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class StringToFile {

	public static void stringToFile(String content, File file){
        if(content==null){
            return;
        }
        FileOutputStream fos=null;
        try {
            if(!file.getParentFile().exists()){
                file.getParentFile().mkdirs();
            }
            fos = new FileOutputStream(file);
            fos.write(content.getBytes());
            fos.flush();
            fos.close();
        } catch (Exception e) {
            if(fos!=null){
                try {
                    fos.close();
                } catch (IOException e1) {}
            }
        }
    }
	
	public static void main(String[] args) {
		stringToFile("hell world",new File("d:\\kill.txt"));
	}

}
